
function HTTP() {
 var xmlhttp
  try {
   xmlhttp = new XMLHttpRequest();
  } catch (e) {
   xmlhttp=false
  }
 return xmlhttp
}
if (typeof postURL=='undefined') {
 postURL=function(url,txt,fn,type,enc) {
  var xmlhttp=new HTTP();
  if (xmlhttp) {
   xmlhttp.open("POST",url,true);
   if (enc) xmlhttp.setRequestHeader("Content-Encoding",enc)
   if (type) xmlhttp.setRequestHeader("Content-Type",type)
   xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4) {
					try {		
      fn({success:xmlhttp.status,content:xmlhttp.responseText,
      	contentType:xmlhttp.getResponseHeader("Content-Type")})
					} catch (e) {
						fn.operationComplete({success:xmlhttp.status,content:xmlhttp.responseText,contentType:xmlhttp.getResponseHeader("Content-Type")})
     }
    }
   }
   xmlhttp.send(txt)
  } else {
  alert("trugudu")
   //Some Appropriate Fallback...
  }
 }
}

if (typeof printNode=='undefined') {
printNode= function (el) {
   return (new XMLSerializer()).serializeToString(el);
};
}

function getDataFile(myUrlString , useData) {
	//call getURL() if available
	if (window.getURL) {
		getURL(myUrlString , useData);
	}
	else
	//call XMLHttpRequest() if available
	if (window.XMLHttpRequest) {
		function XMLHttpRequestCallback() {
			if (xmlRequest.readyState == 4) {
				useData({success:xmlRequest.status,content:xmlRequest.responseText,contentType:xmlRequest.getResponseHeader("Content-Type")})
			}
		}
		var xmlRequest = null;
		xmlRequest = new XMLHttpRequest();
		xmlRequest.open("GET",myUrlString,true);
		xmlRequest.onreadystatechange = XMLHttpRequestCallback;
		xmlRequest.send(null);
	}
	//write an error message if either method is not available
	else {
		alert("your browser/svg viewer neither supports window.getURL nor window.XMLHttpRequest!");
	}		
}

function getSVGObject(myUrlString , addSVGObject) {
	//call getURL() if available
	if (window.getURL) {
		MyaddObject = addSVGObject;
		getURL(myUrlString,addObjectGetURL);
	}
	else
	//call XMLHttpRequest() if available
	if (window.XMLHttpRequest) {
		//this nested function is used to make XMLHttpRequest threadsafe
		//(subsequent calls would not override the state of the request and can use the variable/object context of the parent function)
		//this idea is borrowed from http://www.xml.com/cs/user/view/cs_msg/2815 (brockweaver)
		function XMLHttpRequestCallback() {
			if (xmlRequest.readyState == 4) {
				if (xmlRequest.status == 200) {
						//parse and import the SVG fragment
						var importedNode = document.importNode(xmlRequest.responseXML.documentElement,true);
						//call function addGeom
						addSVGObject(importedNode)
				}
			}
		}
		var xmlRequest = null;
		xmlRequest = new XMLHttpRequest();
		xmlRequest.open("GET",myUrlString,true);
		xmlRequest.onreadystatechange = XMLHttpRequestCallback;
		xmlRequest.send(null);
	}
	//write an error message if either method is not available
	else {
		alert("your browser/svg viewer neither supports window.getURL nor window.XMLHttpRequest!");
	}		
}

//this function is only necessary for getURL()
function addObjectGetURL(data) {
	//check if data has a success property
	if (data.success) {
		//parse content of the XML format to the variable "node"
		var node = parseXML(data.content, document);
		var importedNode = node.firstChild
		MyaddObject(importedNode);
	}
	else {
		alert("something went wrong with dynamic loading of geometry!");
	}
}

